home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: MegaDisc / MegaDisc 02 (1987)(MegaDisc Digital Publishing)(AU)[WB].zip / MegaDisc 02 (1987)(MegaDisc Digital Publishing)(AU)[WB].adf / PROGRAMS / MemTest (.txt) < prev    next >
AmigaBASIC Source Code  |  1987-04-21  |  10KB  |  472 lines

  1. REM***********************************************************
  2. REM*** MEMORY TEST *******************************************
  3. REM***********************************************************
  4.  
  5.   CLS
  6.   SAY TRANSLATE$("")
  7.   WindowId=2
  8.   GOSUB Openwindow
  9.   GOSUB ScreenTrick
  10.   Score=0
  11.   ScnWidth=36
  12.   Combine$="What is your first name? "
  13.   GOSUB NarrPrint
  14.   LINE INPUT ">";FirstName$
  15.   Combine$="Please seed my random number generator by pausing briefly and then pressing any key. "
  16.   GOSUB NarrPrint
  17.   BuffEmpty
  18.   WHILE INKEY$=""
  19.     Seed=Seed+1
  20.     IF Seed=32000 THEN Seed=1
  21.   WEND
  22.   RANDOMIZE Seed
  23.   BuffEmpty
  24.   Combine$="Type `p' to list the game on your printer. "
  25.   GOSUB NarrPrint
  26.   Prnt$=""
  27.   WHILE Prnt$=""
  28.     Prnt$=INKEY$
  29.   WEND
  30.   BuffEmpty
  31.   Combine$="Do you want instructions? Type `y' if so. "
  32.   GOSUB NarrPrint
  33.   GOSUB WhatToDo
  34.   IF Done$="y" THEN
  35.     f1$(1)="OK, here's how this works. "
  36.     f1$(2)="Concentrate now. Here's what we're gonna do. "
  37.     
  38.     f2$(1)="I'll show "
  39.     f2$(2)="I'll display "
  40.     f2$(3)="I'll flash "
  41.  
  42.     f3$(1)="a string of characters on the screen. "
  43.     f3$(2)="a bunch a numbers or letters. "
  44.     f3$(3)="a pile of stuff in the middle of the screen. "
  45.  
  46.     GOSUB RandNum
  47.     Combine$=f1$(x2)+f2$(x3)+f3$(x3a)+"You type in what you see. No need to type `enter'. "
  48.     GOSUB NarrPrint
  49.   END IF
  50.   
  51.   Choice=0
  52.   WHILE Choice<1 OR Choice>4
  53.     BuffEmpty
  54.     Combine$="Choose a level of difficulty. Type 1 (easy) to 4 (ridiculously difficult). "
  55.     GOSUB NarrPrint
  56.     Choice$=""     
  57.     WHILE Choice$=""
  58.       Choice$=INKEY$
  59.     WEND
  60.     Choice=VAL(Choice$)
  61.   WEND
  62.   
  63. GoGame:  
  64.   GOSUB Game
  65.   IF Choice=4 THEN
  66.     CLS
  67.     GOSUB ScreenTrick
  68.     ScnWidth=75
  69.     GOSUB CloseWindow
  70.     END
  71.   END IF
  72.   Combine$="Want to try a harder one? Type `y' for yes or another key to end. "
  73.   GOSUB NarrPrint
  74.   GOSUB WhatToDo
  75.   IF Done$="y" THEN 
  76.     Choice=Choice+1
  77.     GOTO GoGame
  78.   END IF
  79.   CLS
  80.   ScnWidth=75
  81.   GOSUB ScreenTrick
  82.   GOSUB CloseWindow
  83. END
  84.   
  85. REM***********************************************************
  86.  
  87. MainScreen:                 'Screen Display
  88.   IF Count=1 THEN 
  89.     ColorIt=Yellow
  90.     Border=Red
  91.   ELSEIF Count=2 THEN 
  92.     ColorIt=Red
  93.     Border=Yellow
  94.   ELSEIF Count=3 THEN 
  95.     ColorIt=Blue
  96.     Border=Yellow
  97.   ELSEIF Count=4 THEN 
  98.     ColorIt=Green
  99.     Border=Red
  100.   ELSEIF Count=5 THEN 
  101.     ColorIt=Brown
  102.     Border=Black
  103.   END IF
  104.   
  105.   LINE(0,0)-(319,199),ColorIt,bf
  106.     
  107.   FOR i=1 TO 20    
  108.     LINE(70,118-i)-(240,116+i),0,b
  109.     Pause(30)
  110.   NEXT
  111.   LINE(69,97)-(241,137),Border,b
  112. RETURN
  113.   
  114. UpLeftScreen:
  115.     FOR i=1 TO 10    
  116.     LINE(10,44-i)-(110,42+i),0,b
  117.     Pause(50)
  118.   NEXT
  119.   LINE(9,33)-(111,53),Border,b
  120. RETURN
  121.   
  122. UpRightScreen:  
  123.   FOR i=1 TO 10    
  124.     LINE(190,44-i)-(290,42+i),0,b
  125.     Pause(50)
  126.   NEXT
  127.   LINE(189,33)-(291,53),Border,b
  128. RETURN
  129.   
  130. REM***********************************************************
  131.  
  132. Game:                'Game module
  133.   Delay=9600
  134.   Count=0
  135.   FOR x=1 TO 5
  136.     Count=Count+1
  137.     ON Choice GOSUB Level1, Level2, Level3, Level4
  138.     IF INT(RND*25)=7 THEN
  139.       CLS
  140.       Pause(4000)
  141.       LOCATE 12
  142.       PRINT "    246983027548012469832451078951"
  143.       Pause(Delay)
  144.       CLS
  145.       Combine$="Just kidding."
  146.       GOSUB NarrPrint
  147.     END IF
  148.     CLS
  149.     Pause(4000)
  150.     LOCATE 12,20-Length/2
  151.     PRINT Test$
  152.     Pause(Delay)
  153.     CLS
  154.     Delay=Delay/2
  155.     FOR i=1 TO Length
  156.         Ans$=""
  157.         WHILE Ans$=""
  158.           Ans$=INKEY$
  159.         WEND
  160.         Try$=Try$+Ans$
  161.     NEXT i
  162.     GOSUB ScoreReport
  163.     BuffEmpty
  164.   NEXT x
  165.   CLS
  166. RETURN
  167.  
  168. REM****************************************
  169.  
  170. ScoreReport:
  171.   f1$(1)="Congratulations "
  172.   f1$(2)="Magnificent "
  173.   f1$(3)="You're right "
  174.   f1$(4)="Very good "
  175.   f1$(5)="You did it "
  176.   f1$(6)="Hurray "
  177.  
  178.   f2$(1)="Your score is "
  179.   f2$(2)="Your total score is "
  180.   f2$(3)="Here's your total score "
  181.   f2$(4)="Score total is "
  182.  
  183.   f3$(1)="You goofed. "
  184.   f3$(2)="Wrong. "
  185.   f3$(3)="Nope. "
  186.   f3$(4)="Error. "
  187.   f3$(5)="You screwed up. "
  188.   f3$(6)="You fouled up. "
  189.   f3$(7)="Uh oh. "
  190.   f3$(8)="You blew it. "
  191.   f3$(9)="Stupendous stupidity. "
  192.   
  193.   GOSUB RandNum
  194.   IF Try$=Test$ THEN
  195.     Combine$=f1$(x6)+FirstName$+". "+f2$(x4)
  196.     Score=Score+ScoreIncrement
  197.   ELSE 
  198.     Combine$=f3$(x9)+"Your score is still "
  199.   END IF
  200.   GOSUB NarrPrint
  201.   CLS
  202.   GOSUB MainScreen  
  203.   LOCATE 15,20-LEN(STR$(Score))/2
  204.   PRINT Score
  205.   PronounceNum(Score)
  206.   SAY TRANSLATE$(NumPron$)
  207.   IF Prnt$="p" THEN LPRINT Score: LPRINT
  208.   Combine$="I said "
  209.   GOSUB NarrWithLPrint
  210.   GOSUB UpLeftScreen
  211.   LOCATE 6,8-Length/2
  212.   PRINT Test$
  213.   Combine$=Test$
  214.   GOSUB NarrWithLPrint
  215.   Combine$="You typed "
  216.   GOSUB NarrWithLPrint
  217.   GOSUB UpRightScreen
  218.   LOCATE 6,31-Length/2
  219.   PRINT Try$
  220.   Combine$=Try$+". "
  221.   GOSUB NarrWithLPrint
  222.   Pause(5000)
  223. RETURN
  224.   
  225. REM**********************************************************
  226.  
  227. Level1:
  228.   Test$=""
  229.   Try$=""
  230.   ScoreIncrement=10
  231.   Length=5
  232.   FOR i=1 TO 5
  233.    Test$=Test$+RIGHT$(STR$(INT(RND*10)),1)
  234.   NEXT i
  235. RETURN
  236.   
  237. REM**********************************************************
  238.  
  239. Level2:
  240.   Test$=""
  241.   Try$=""
  242.   ScoreIncrement=20
  243.   Length=6
  244.   FOR i=1 TO 6
  245.    Test$=Test$+CHR$(INT(RND*26)+97)
  246.   NEXT i
  247. RETURN
  248.  
  249. REM**********************************************************
  250.  
  251. Level3:
  252.   Test$=""
  253.   Try$=""
  254.   ScoreIncrement=50
  255.   Length=7
  256.   FOR i=1 TO 7
  257.     Test$=Test$+RIGHT$(STR$(INT(RND*10)),1)
  258.   NEXT i
  259. RETURN 
  260.  
  261. REM*********************************************************
  262.  
  263. Level4:
  264.   Test$=""
  265.   Try$=""
  266.   ScoreIncrement=100
  267.   Length=7
  268.   FOR i=1 TO 7
  269.     Test$=Test$+CHR$(INT(RND*26)+97)
  270.   NEXT i
  271. RETURN
  272.  
  273. REM*********************************************************
  274.  
  275. WhatToDo:
  276.   Done$=""
  277.   WHILE Done$=""
  278.     Done$=INKEY$
  279.   WEND
  280. RETURN
  281.  
  282. REM*********************************************************
  283.   
  284. SUB Pause(Hold) STATIC
  285.   FOR i=1 TO Hold
  286.   NEXT i
  287. END SUB
  288.  
  289. REM*********************************************************
  290.  
  291. SUB BuffEmpty STATIC
  292.   FOR i=1 TO 20
  293.     ThrowAway$=INKEY$
  294.   NEXT
  295. END SUB
  296.  
  297. REM***********************************************************
  298.  
  299. ScreenTrick:
  300.   ColorIt=Yellow
  301.   LINE(5,5)-(319,199),Red,bf
  302.   FOR i=5 TO 199
  303.     LINE(INT(1.6*i),i)-(319-INT(1.6*i),199-i),ColorIt,b
  304.     IF i=99 THEN ColorIt=Blue
  305.   NEXT
  306.   CLS
  307. RETURN
  308.  
  309. REM***********************************************************
  310.  
  311. Openwindow:
  312.   SCREEN 1,320,200,5,1
  313.   WINDOW WindowId,,,,1
  314.   GOSUB ColorDef
  315. RETURN
  316.  
  317. REM************************************************************
  318.   
  319. CloseWindow:
  320.   WindowId=WindowId+1
  321.   SCREEN CLOSE 1
  322. RETURN
  323.  
  324. REM************************************************************
  325.  
  326. ColorDef:
  327.   DarkBlue=0
  328.   White=1
  329.   Black=2
  330.   Orange=3
  331.   Red=5 
  332.   Yellow=6
  333.   LightBlue=7
  334.   Brown=9
  335.   Green=10
  336.   Gray=13
  337.   Blue=14
  338.   
  339.   PALETTE Red,1,0.1,0
  340.   PALETTE Yellow,1,1,0.13
  341.   PALETTE Blue,0.4,0.6,1
  342.   PALETTE Brown,0.8,0.6,0.53
  343.   PALETTE Green,0.33,0.87,0
  344.   PALETTE Gray,0.73,0.73,0.73
  345.   PALETTE LightBlue,0.47,0.87,1
  346. RETURN  
  347.     
  348. REM***********************************************************
  349.  
  350. NarrWithLPrint:
  351.   SAY TRANSLATE$(Combine$)
  352.   IF Prnt$="p" THEN LPRINT Combine$: LPRINT
  353. RETURN
  354.  
  355. REM***********************************************************
  356. REM*** RANDOM NUMBER MODULE **********************************
  357. REM***********************************************************
  358.  
  359. RandNum:
  360.   x2=INT(RND*2)+1:x3=INT(RND*3)+1: x4=INT(RND*4)+1: x5=INT(RND*5)+1: x6=INT(RND*6)+1: x7=INT(RND*7)+1: x8=INT(RND*8)+1: x9=INT(RND*9)+1: x10=INT(RND*10)+1
  361.   x2a=INT(RND*2)+1: x2b=INT(RND*2)+1
  362.   x3a=INT(RND*3)+1: x3b=INT(RND*3)+1: x3c=INT(RND*3)+1
  363.   x4a=INT(RND*4)+1: x4b=INT(RND*4)+1
  364.   x5a=INT(RND*5)+1: x5b=INT(RND*5)+1: x5c=INT(RND*5)+1
  365.   x7a=INT(RND*7)+1: x7b=INT(RND*7)+1
  366. RETURN
  367.  
  368. REM***********************************************************
  369. REM*** NARRATION AND PRINT MODULE ****************************
  370. REM***********************************************************
  371.  
  372. NarrPrint:
  373.   PRINT
  374.   Comb$=TRANSLATE$(Combine$)
  375.   GOSUB FlushLeft
  376.   IF Prnt$="p" THEN LPRINT Combine$: LPRINT
  377.   PRINT
  378.   SAY (Comb$)
  379. RETURN
  380.  
  381. REM***********************************************************
  382.  
  383. FlushLeft:
  384.   Lines=ScnWidth: StopIt=LEN(Combine$)+1: Pointer=1
  385.   WHILE Lines<StopIt
  386.     TestIt$=MID$(Combine$,Lines,1)
  387.     IF TestIt$<>" " THEN
  388.       WHILE MID$(Combine$,Lines,1)<>" "
  389.         Lines=Lines-1                      
  390.       WEND 
  391.       PRINT MID$(Combine$,Pointer,Lines-Pointer)
  392.       Pointer=Lines+1
  393.       Lines=Lines+ScnWidth
  394.     ELSE 
  395.       PRINT MID$(Combine$,Pointer,Lines-Pointer)
  396.       Pointer=Lines+1
  397.       Lines=Lines+ScnWidth
  398.     END IF
  399.   WEND
  400.   PRINT RIGHT$(Combine$,StopIt-Pointer)
  401. RETURN
  402.  
  403. REM***********************************************************
  404. REM*** NUMBER PRONUNCIATION **********************************
  405. REM***********************************************************
  406.  
  407. SUB PronounceNum(NumPron) STATIC
  408.   SHARED NumPron$
  409.   IF NumPron<0 THEN Sign$="neguhtiv " :ELSE Sign$=""
  410.   Num=ABS(NumPron)
  411.   IF Num<10 OR Num>=1000 THEN NumPron$=Sign$+STR$(Num): EXIT SUB
  412.   Hund$=""
  413.   IF Num<100 THEN
  414.     Num$=STR$(Num)
  415.   ELSE
  416.     Num$=" "+MID$(STR$(Num),3)
  417.   END IF
  418.   One$=MID$(Num$,3,1)
  419.   IF Num>=100 THEN ON FIX(Num/100) GOSUB 100,200,300,400,500,600,700,800,900
  420.   IF Num>=10 THEN
  421.     IF Num>=20 THEN
  422.       IF One$="0" THEN
  423.         Fraction$=MID$(Num$,4)
  424.       ELSE 
  425.         Fraction$=MID$(Num$,3)
  426.       END IF
  427.     END IF
  428.     ON FIX(Num/10) GOSUB 10, 20, 30, 40, 50, 60, 70, 80, 90
  429.   ELSEIF Num=0 THEN
  430.     Pr$=""
  431.   ELSEIF Num<1 THEN
  432.     Pr$=MID$(Num$,4)
  433.   ELSE
  434.     Pr$=MID$(Num$,3)
  435.   END IF
  436.   NumPron$=Sign$+Hund$+Pr$
  437. EXIT SUB
  438.                  
  439.   10 Fraction$=MID$(Num$,4)
  440.      IF One$="0" THEN Pr$="ten "       +Fraction$: RETURN
  441.      IF One$="1" THEN Pr$="eelevven "  +Fraction$: RETURN
  442.      IF One$="2" THEN Pr$="twelve "    +Fraction$: RETURN
  443.      IF One$="3" THEN Pr$="thir-teen " +Fraction$: RETURN
  444.      IF One$="4" THEN Pr$="for-teen "  +Fraction$: RETURN
  445.      IF One$="5" THEN Pr$="fif-teen "  +Fraction$: RETURN
  446.      IF One$="6" THEN Pr$="six-teen "  +Fraction$: RETURN
  447.      IF One$="7" THEN Pr$="seven-teen "+Fraction$: RETURN
  448.      IF One$="8" THEN Pr$="ate-teen "  +Fraction$: RETURN
  449.      IF One$="9" THEN Pr$="nine-teen " +Fraction$: RETURN
  450.  
  451.   20 Pr$="twentee " +Fraction$: RETURN
  452.   30 Pr$="thirtee " +Fraction$: RETURN
  453.   40 Pr$="fortee "  +Fraction$: RETURN
  454.   50 Pr$="fiftee "  +Fraction$: RETURN
  455.   60 Pr$="sixtee "  +Fraction$: RETURN
  456.   70 Pr$="seventee "+Fraction$: RETURN
  457.   80 Pr$="ate-ee "  +Fraction$: RETURN
  458.   90 Pr$="nine-tee "+Fraction$: RETURN
  459.  
  460.  100 Hund$="one hundredd "  : Num=Num-100: RETURN
  461.  200 Hund$="two hundredd "  : Num=Num-200: RETURN
  462.  300 Hund$="three hundredd ": Num=Num-300: RETURN
  463.  400 Hund$="four hundredd " : Num=Num-400: RETURN
  464.  500 Hund$="five hundredd " : Num=Num-500: RETURN
  465.  600 Hund$="six hundredd "  : Num=Num-600: RETURN
  466.  700 Hund$="seven hundredd ": Num=Num-700: RETURN
  467.  800 Hund$="ate hundredd "  : Num=Num-800: RETURN
  468.  900 Hund$="nine hundredd " : Num=Num-900: RETURN 
  469.     
  470. END SUB
  471.  
  472.